package com.isunland.managesystem.ui;

import com.google.gson.Gson;
import com.isunland.managesystem.base.BaseNetworkDialogFragment;
import com.isunland.managesystem.common.ApiConst;
import com.isunland.managesystem.entity.CurrentUser;
import com.isunland.managesystem.entity.CustomerDialog;
import com.isunland.managesystem.entity.MaterielLomContent;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * Created by lenovo on 2016/7/18.
 */
public class MaterielKindDialogFragment extends BaseNetworkDialogFragment {
  @Override public ArrayList<CustomerDialog> resolveResponse(String arg0) {
    ArrayList<CustomerDialog> list = new ArrayList<CustomerDialog>();
    MaterielLomContent[] dataList = new Gson().fromJson(arg0, MaterielLomContent[].class);

    if (dataList == null || dataList.length == 0) {

      return null;
    }
    for (int i = 0; i < dataList.length; i++) {
      list.add(new CustomerDialog(dataList[i].getName(), dataList[i].getId()));
    }
    return list;
  }

  @Override public String getUrl() {
    return ApiConst.URL_MATERIE_LOM;
  }

  @Override public HashMap<String, String> getparameters() {
    HashMap<String, String> params = new HashMap<>();
    params.put("memberCode", CurrentUser.newInstance(getActivity()).getMemberCode());
    params.put("dataStatus", "publish");
    params.put("materialKindCodeLength", "2");
    return params;
  }
}
